using System;

namespace Axe.Geometry
{
	/// <summary>
	/// Summary description for AABB.
	/// </summary>
	public class AxisAlignedBox
	{
		public Vector3 mCenter = new Vector3();
		public Vector3 mSize = new Vector3();

		public double[] X = new double [2];
		public double[] Y = new double [2];
		public double[] Z = new double [2];

		public AxisAlignedBox()
		{

		}

		public void UpdateXYZ()
		{
			/*
			X[0] = mCenter.X - mSize.X/2;
			X[1] = mCenter.X + mSize.X/2;

			Y[0] = mCenter.Y - mSize.Y/2;
			Y[1] = mCenter.Y + mSize.Y/2;

			Z[0] = mCenter.Z - mSize.Z/2;
			Z[1] = mCenter.Z + mSize.Z/2;
			*/
			X[0] = - mSize.X/2;
			X[1] = + mSize.X/2;

			Y[0] = - mSize.Y/2;
			Y[1] = + mSize.Y/2;

			Z[0] = - mSize.Z/2;
			Z[1] = + mSize.Z/2;
		}

		public AxisAlignedBox(Vector3 center,Vector3 size)
		{
			mCenter.Set(center);
			mSize.Set(size);

			UpdateXYZ();
		}

		public static AxisAlignedBox FromCenterAndSize(Vector3 center,Vector3 size)
		{
			AxisAlignedBox b = new AxisAlignedBox();
			b.mCenter.Set(center);
			b.mSize.Set(size);
			b.UpdateXYZ();
			return b;
		}
	}
}
